package com.fangcun.controller.api.old;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.fangcun.bean.sys.ResponseMsg;
import com.fangcun.common.canstant.ErrCode;
import com.fangcun.common.exception.ProException;
import com.fangcun.common.util.PublicMethod;
import com.fangcun.common.util.apiversion.ApiVersion;
import com.fangcun.service.api.GoodsCategoryServicer;

@RestController
@RequestMapping("/api/{version}/goods/category")
public class GoodsCategoryApiController {
	
	private static Logger LOG = LoggerFactory.getLogger(GoodsCategoryApiController.class);
	
	@Autowired
	private GoodsCategoryServicer goodsCategoryServicer;
	
	@ApiVersion(1.0)
	@RequestMapping("list")
	private ResponseMsg list(Long teahouseId) {
		ResponseMsg msg = ResponseMsg.returnBeanBuild();
		try {
			msg.setData(goodsCategoryServicer.list(teahouseId));
		} catch (ProException e) {
			LOG.error("-商品分类-列表出错->{},{},{}", msg.getSessionId(), e.getErrorCode(), e.getErrorMsg());
			msg.setReturnCode(e.getErrorCode()).setReturnMsg(e.getErrorMsg());
		} catch (Exception e) {
			LOG.error("-商品分类-列表异常->{},{}", msg.getSessionId(), PublicMethod.printErrorTrace(e));
			msg.setReturnCode(ErrCode.ERR.getReturnCode()).setReturnMsg(ErrCode.ERR.getReturnMsg());
		}
		return msg;
	}
}
